//
//  DeliveryPWDController.m
//  AntsExpress
//
//  Created by Home on 16/1/16.
//  Copyright © 2016年 slccper. All rights reserved.
//

#import "DeliveryPWDController.h"

@interface DeliveryPWDController ()
@property (weak, nonatomic) IBOutlet UITextField *OldPWD;
@property (weak, nonatomic) IBOutlet UITextField *NewPWD;
@property (weak, nonatomic) IBOutlet UITextField *ReNew;
@property (weak, nonatomic) IBOutlet UILabel *lbPWD;

@end

@implementation DeliveryPWDController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.OldPWD.text = [clsOtherFun getResivePwd];
    ants = [[clsAntsService alloc]init];
    ants.delegate=self;
    // Do any additional setup after loading the view from its nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)ChangeAction:(id)sender {
    NSString *NewPWD = self.NewPWD.text;
    if ([NewPWD isEqualToString:@""]) {
        [clsOtherFun ShowMsg:@"請輸入新收貨密碼"];
        [self.NewPWD becomeFirstResponder];
        return;
    }
    NSString *ReNew = self.ReNew.text;
    if ([ReNew isEqualToString:@""]) {
        [clsOtherFun ShowMsg:@"請確認新收貨密碼"];
        [self.ReNew becomeFirstResponder];
        return;
    }
    if (![NewPWD isEqualToString:ReNew]) {
        [clsOtherFun ShowMsg:@"兩次密碼不一致"];
        [self.ReNew becomeFirstResponder];
        return;
    }
    
    [clsOtherFun showLoadingView:@"正在更新數據..."];
    [ants ResivePwd:ReNew];
}
-(void)getAntsDataSuccess:(NSInteger)type :(NSMutableDictionary *)pDictionary
{
    [clsOtherFun hideLoadingView];
    NSDictionary *dic = [pDictionary objectForKey:@"data"];
    NSString *status = [dic objectForKey:@"status"];
    if ([status integerValue]==200) {
        [clsOtherFun ShowMsg:@"更新成功！"];
        [self.navigationController popViewControllerAnimated:YES];
    }else{
        [clsOtherFun ShowMsg:[dic objectForKey:@"message"]];
    }
    
}

@end
